package com.ctgu.expresshelper.controller;

import com.ctgu.expresshelper.entity.User;
import com.ctgu.expresshelper.service.User.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 微信登录
     * @param username
     * @param imgUrl
     * @param code
     * @return
     */
    @RequestMapping("/getOpenId")
    @ResponseBody
    public User getWxOpenId(String username,String imgUrl,String code){
        return  userService.getUserOpenId(username,imgUrl,code);
    }


    /**
     * 根据用户id 修改 sendnum
     * @param userId
     * @param receiveNum
     * @return
     */
    @RequestMapping("/updateReceiveNum")
    @ResponseBody
    public int updateReceiveNum(int userId,int receiveNum){
        return  userService.updateReceiveNum(userId,receiveNum);
    }


    /**
     * 根据用户id 修改 receiveNum
     * @param userId
     * @param sendNum
     * @return
     */
    @RequestMapping("/updateSendNum")
    @ResponseBody
    public int updateSendNumNum(int userId,int sendNum){
        return  userService.updateSendNumNum(userId,sendNum);
    }

}
